//
//  BKTwoCollectionModel.m
//  FastBee
//
//  Created by mac on 16/9/11.
//  Copyright © 2016年 xbk. All rights reserved.
//

#import "BKTwoCollectionModel.h"

#import "BKNetWorkTools.h"

@implementation BKTwoCollectionModel


- (void)setValue:(id)value forUndefinedKey:(NSString *)key{};

+ (instancetype)twoCollectionModelWithDic:(NSDictionary *)dic{

    BKTwoCollectionModel *model = [[BKTwoCollectionModel alloc]init];
    [model setValuesForKeysWithDictionary:dic];
    return model;
}


+ (void)downloadDataWithUrl:(NSString *)url successBlock:(void(^)(NSArray *arr))successBlock failBlock:(void(^)(NSError *error))failBlock{
    
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    [dic setValue:@"2" forKey:@"call"];
    
    [[BKNetWorkTools shareNetWorkTools]POST:url parameters:dic progress:nil success:^(NSURLSessionDataTask * _Nonnull task,NSDictionary *responseObject) {
        
        NSArray *arr = responseObject[@"data"];
        NSMutableArray *arrM = [NSMutableArray arrayWithCapacity:arr.count];
        
        for (NSDictionary *dic in arr) {
            
            BKTwoCollectionModel *model = [BKTwoCollectionModel twoCollectionModelWithDic:dic];
            [arrM addObject:model];
        }
        if (successBlock) {
            
            successBlock(arrM.copy);
        }
        //NSLog(@"%@",responseObject);
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
        if (failBlock) {
            
            failBlock(error);
        }
    }];
}

@end
